package com.mapResult.domain;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface BusDataBaseMapStruct {

    public static final BusDataBaseMapStruct INSTANCE = Mappers.getMapper(BusDataBaseMapStruct.class);

    @Mapping(expression = "java( com.alibaba.fastjson.JSON.toJSONString(busDataBaseInfoVO.getColumns(), com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue) )", target = "columns")
    @Mapping(expression = "java( com.alibaba.fastjson.JSON.toJSONString(busDataBaseInfoVO.getColumnMappings(), com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue) )", target = "columnMappings")
    BusDataBaseInfo Vo2Dto(BusDataBaseInfoVO busDataBaseInfoVO);

    @Mapping(expression = "java( com.alibaba.fastjson.JSON.parseObject(busDataBaseInfo.getColumns(), java.util.HashMap.class) )", target = "columns")
    @Mapping(expression = "java( com.alibaba.fastjson.JSON.parseObject(busDataBaseInfo.getColumnMappings(), java.util.HashMap.class) )", target = "columnMappings")
    BusDataBaseInfoVO Dto2Vo(BusDataBaseInfo busDataBaseInfo);

    @Mapping(expression = "java( com.alibaba.fastjson.JSON.parseObject(busDataBaseInfo.getColumns(), java.util.HashMap.class) )", target = "columns")
    @Mapping(expression = "java( com.alibaba.fastjson.JSON.parseObject(busDataBaseInfo.getColumnMappings(), java.util.HashMap.class) )", target = "columnMappings")
    List<BusDataBaseInfoVO> Dto2Vo(List<BusDataBaseInfo> busDataBaseInfos);

}
